package com.qk.management.controller;

import com.qk.dto.activity.ActivityDTO;
import com.qk.entity.Activity;
import com.qk.management.service.ActivityService;
import com.qk.result.PageResult;
import com.qk.result.Result;
import com.qk.vo.activity.ActivityQueryVO;
import com.qk.vo.activity.ActivityVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:zhengbowen
 * @Date: 2025/10/10 19:36
 * @Description: 活动管理控制器
 */
@Slf4j
@RestController
@RequestMapping("/activities")
@RequiredArgsConstructor
public class ActivityController {

    private final ActivityService activityService;

    @GetMapping("/type/{type}")
    public Result selectActivityListByType(@PathVariable Integer type) {
        List<ActivityVO> activityVOList = activityService.selectActivityListByType(type);
        return Result.success(activityVOList);
    }

    @DeleteMapping("{id}")
    public Result deleteActivity(@PathVariable Integer id) {
        activityService.deleteActivity(id);
        return Result.success();
    }

    @DeleteMapping("")
    public Result deleteBatchActivity(@RequestBody List<Integer> ids) {
        activityService.deleteBatchActivities(ids);
        return Result.success();
    }

    @PostMapping("")
    public Result insertActivity(@RequestBody Activity activity) {
        activityService.insertActivity(activity);
        return Result.success();
    }

    @PutMapping("")
    public Result updateActivity(@RequestBody Activity activity) {
        activityService.updateActivity(activity);
        return Result.success();
    }

    @GetMapping("/list")
    public Result selectActivityList() {
        List<ActivityVO> activityVOList = activityService.selectActivityList();
        return Result.success(activityVOList);
    }

    @GetMapping("/{id}")
    public Result selectActivityById(@PathVariable("id") Long id) {
        ActivityVO activityVO = activityService.selectActivityById(id);
        return Result.success(activityVO);
    }

    @GetMapping("")
    public Result selectActivitiesByPage(ActivityDTO activityDTO) {
         PageResult<ActivityQueryVO> pageResult  = activityService.selectActivitiesByPage(activityDTO);
        return Result.success(pageResult);
    }
}
